package com.jetbrains.kmpapp.feature.payment

import kotlinx.coroutines.flow.Flow

expect object InAppPurchaseService {
    val purchaseResultFlow: Flow<PurchaseResult> // 通过 Flow 接收购买结果

    fun purchase(productId: String, uuid: String) // 发起购买
    fun restorePurchases() // 恢复购买
    fun dispose()
}

// 共享的交易结果
sealed class PurchaseResult {
    data class Success(val productId: String, val transactionId: String) : PurchaseResult()
    data class Error(val message: String) : PurchaseResult()
    data object Cancelled : PurchaseResult()
    data object Deferred : PurchaseResult()
}